import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AccountsVO, AccountsForm, AccountsQuery } from '@/api/tearoom/accounts/types';

/**
 * 查询账户列表
 * @param query
 * @returns {*}
 */

export const listAccounts = (query?: AccountsQuery): AxiosPromise<AccountsVO[]> => {
  return request({
    url: '/tearoom/accounts/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询账户详细
 * @param id
 */
export const getAccounts = (id: string | number): AxiosPromise<AccountsVO> => {
  return request({
    url: '/tearoom/accounts/' + id,
    method: 'get'
  });
};

/**
 * 新增账户
 * @param data
 */
export const addAccounts = (data: AccountsForm) => {
  return request({
    url: '/tearoom/accounts',
    method: 'post',
    data: data
  });
};

/**
 * 修改账户
 * @param data
 */
export const updateAccounts = (data: AccountsForm) => {
  return request({
    url: '/tearoom/accounts',
    method: 'put',
    data: data
  });
};

/**
 * 删除账户
 * @param id
 */
export const delAccounts = (id: string | number | Array<string | number>) => {
  return request({
    url: '/tearoom/accounts/' + id,
    method: 'delete'
  });
};

export const unfrozen = (data: AccountsForm) => {
  return request({
    url: '/tearoom/accounts/unfrozen',
    method: 'post',
    data: data
  });
};